package cn.itcast.hotel.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MqConfig {
    //声明主题交换机
    @Bean
    public TopicExchange hotelTopic(){
        return new TopicExchange("hotel.topic");
    }
    //声明增加队列
    @Bean
    public Queue hotelInsertQueue(){
        return new Queue("hotel.insert.queue");
    }
    //声明删除队列
    @Bean
    public Queue hotelDeleteQueue(){
        return new Queue("hotel.delete.queue");
    }
    @Bean
    public Binding bindingInsertQueue(){
      return   BindingBuilder.bind(hotelInsertQueue()).to(hotelTopic()).with("hotel.insert");
    }
    @Bean
    public Binding bindingDeleteQueue(){
        return   BindingBuilder.bind(hotelDeleteQueue()).to(hotelTopic()).with("hotel.delete");
    }
}
